import request from '@/utils/request'

export function getFunctionPages(params) {
  return request({
    url: '/sys/function/getPage',
    method: 'get',
    params
  })
}

export function getFunctionTree(params) {
  return request({
    url: '/sys/function/getTree',
    method: 'get',
    params
  })
}

export function getUserFunctionTree(params) {
  return request({
    url: '/sys/function/getUserFTree',
    method: 'get',
    params
  })
}

export function getFunctionById(params) {
  return request({
    url: '/sys/function/selectById',
    method: 'get',
    params
  })
}

export function functionAdd(data) {
  return request({
    url: '/sys/function/save',
    method: 'post',
    data
  })
}

export function functionUpdate(data) {
  return request({
    url: '/sys/function/edit',
    method: 'post',
    data
  })
}

export function functionUpdateDisabled(ids, enable) {
  let _ids = []
  if (Array.isArray(ids)) _ids = ids
  else _ids = [ids]
  return request({
    method: 'get',
    url: '/sys/function/updateStatus',
    params: {
      ids: _ids.join(','),
      status: enable
    }
  })
}

export function functionDel(params) {
  return request({
    url: '/sys/function/delete',
    method: 'get',
    params
  })
}

export function functionToggleHidden(params) {
  return request({
    url: '/sys/function/toggleHidden',
    method: 'get',
    params
  })
}
